//
//  SHintergralStoreViewController.m
//  WHstoreItemProtect
//
//  Created by 宋媛媛 on 2017/11/8.
//  Copyright © 2017年 sdwh.com. All rights reserved.
//

#import "SHintergralStoreViewController.h"
#import "SIntergralCollectionViewCell.h"
#import "SCollectHeaderView.h"
#import "UIColor+Addition.h"

static NSString *const kReuseId = @"SIntergralCollectionViewCell";

static NSString *const kHeaderReuseId = @"SCollectHeaderView";

@interface SHintergralStoreViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (nonatomic,strong) UICollectionView *collectionView;
@property (nonatomic,strong) UICollectionViewFlowLayout *flowLayout;

@end

@implementation SHintergralStoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithHex:0xFF6800];
    
    [self creatUI];
}

- (void)creatUI{
    self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
    self.flowLayout.minimumLineSpacing = 10;
    self.flowLayout.minimumInteritemSpacing = 0;
    self.flowLayout.itemSize = CGSizeMake(kUIScreenWidth/2-5, (kUIScreenWidth/2-5)-16+77);
    self.flowLayout.headerReferenceSize = CGSizeMake(kUIScreenWidth, 215*kUIScreenWidth/375+45);
    self.flowLayout.sectionInset = UIEdgeInsetsMake(10, 0, 10, 0);
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) collectionViewLayout:self.flowLayout ];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [self.collectionView registerNib:[UINib nibWithNibName:kReuseId bundle:nil] forCellWithReuseIdentifier:kReuseId];
    [self.collectionView registerNib:[UINib nibWithNibName:kHeaderReuseId bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kHeaderReuseId];
    self.collectionView.dataSource = self;
    self.collectionView.delegate = self;
    [self.view addSubview:self.collectionView];
}

#pragma mark - UICollectionViewDataSource, UICollectionViewDelegate
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 4;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    SIntergralCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kReuseId forIndexPath:indexPath];
    return cell;
}

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    if (kind == UICollectionElementKindSectionFooter) {
        return nil;
    }
    SCollectHeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kHeaderReuseId forIndexPath:indexPath];
    return headerView;
}

@end
